package com.twu.biblioteca;


import java.io.BufferedReader;
import java.util.Date;

/**
 * Created by abhishekpuri on 10/5/14.
 */

public class Book {

    private String _Name;
    private String _AuthorName;
    private Date _PublishingDate;
    private IOHandler _ioHandler;

    public Book() {
        _Name = _AuthorName = null;
        _PublishingDate = null;
        _ioHandler=new IOHandler();
    }

    public Book(String name, String authorName, Date pubDate) {
        _Name=name;
        _AuthorName=authorName;
        _PublishingDate=pubDate;
        _ioHandler=new IOHandler();
    }

    public Book(String name, String authorName, Date pubDate, BufferedReader inStream) {
        _Name=name;
        _AuthorName=authorName;
        _PublishingDate=pubDate;
        _ioHandler=new IOHandler(inStream);
    }

    public void setName() {
        _ioHandler.printlnToConsole("Enter the name of the book : ");
        _Name = _ioHandler.readString();  // Production code
    }

    public void setName(String name) {
        _Name=name;
    }

    public void setAuthorName() {
        _ioHandler.printlnToConsole("Enter the author's name : ");
        _AuthorName= _ioHandler.readString();
    }

    public void setAuthorName(String name) {
        _AuthorName=name;
    }

    public void setPublishingDate() {
        _ioHandler.printlnToConsole("Enter the publishing date (dd/mm/yyyy) : ");
        _PublishingDate = _ioHandler.readDate();
    }

    public void setPublishingDate(Date pubDate) {
        _PublishingDate = pubDate;
    }

    public String getName() {
        return _Name;
    }

    public String getAuthorName() {
        return _AuthorName;
    }

    public Date getPublishingDate() {
        return _PublishingDate;
    }
}
